<?php

declare(strict_types=1);

namespace App\Request\My;

use App\Request\BaseCommonRequest;
use Hyperf\Context\Context;
use Hyperf\Validation\Request\FormRequest;

class VideoActionRequest extends BaseCommonRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'action' => 'required|in:delete,update,insert',
            'id' => 'required_if:action,delete,update|array',
            'is_recommend' => 'required_if:action,update,insert',
            'first_photo' => 'required_if:action,insert',
            'video_url' => 'required_if:action,insert',
        ];
    }

    // public function messages(): array
    // {
    //     $language = Context::get('language');
    //     if ($language == 'zh-zn') {
    //         return [
    //             'id.required' => '视频id不能为空',
    //             'id.array' => '视频id必须为数组',
    //             'action.required' => '操作不能为空',
    //             'action.in' => '操作只能为delete,update',
    //             'is_recommend.required_if' => '更新时，是否推荐不能为空',
    //         ];
    //     } elseif ($language == 'zh-hk') {
    //         return [
    //             'id.required' => '視頻id不得為空',
    //             'id.array' => '視頻id必須為數組',
    //             'action.required' => '操作不得為空',
    //             'action.in' => '操作只能為delete,update',
    //             'is_recommend.required_if' => '更新時，是否推薦不得為空',
    //         ];
    //     } else {
    //         return [
    //             'id.required' => 'Video id cannot be empty',
    //             'id.array' => 'Video id must be an array',
    //             'action.required' => 'Action cannot be empty',
    //             'action.in' => 'Action can only be delete,update',
    //             'is_recommend.required_if' => 'update Is recommend cannot be empty',
    //         ];
    //     }
    // }

}
